package com.xw.lora.enums;

public enum ResultCodeEnum {

    SUCCESS(0,"操作成功"),
    FAIL(1,"操作失败"),

    /*
    通用参数（号段：1000-1999）===========================================================
     */
    //无效的参数
    PARAM_INVALID(1000,"无效参数"),
    //参数值为空值
    PARAM_VAL_IS_EMPTY(1001,"参数值不能为空"),
    //参数的格式不正确
    PARAM_FORMAT_ERR(1002,"参数的格式不正确");


    private int code;
    private String msg;

    private ResultCodeEnum(int statusCode, String msg) {
        this.code = statusCode;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 将类转换成拼接的json字符串
     * @return json格式的字符串
     */
    public String toJsonString(){
        return "{" +
                "\"code\":" + code +
                ",\"msg\":\"" + msg + "\"" +
                "}";
    }
}
